package com.iflyteck.controller;

import com.iflyteck.pojo.Comment;
import com.iflyteck.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class ApiCommentController {

    @Autowired
    @Qualifier("apiCommentServiceImpl")
    private CommentService commentService;

    @RequestMapping("/findCommentById")
    public Comment findCommentById(Integer id) {
        Comment comment = commentService.findCommentById(id);
        return comment;
    }

    @RequestMapping("/updateComment")
    public Comment updateComment(Comment comment) {
        Comment update = commentService.findCommentById(comment.getId());
        update.setAuthor(comment.getAuthor());
        Comment result = commentService.updateComment(update);
        return result;
    }

    @RequestMapping("/deleteComment")
    public void deleteComment(Integer id) {
        commentService.deleteComment(id);
    }

}
